$(function () {
  //教务资讯、通知公告点击切换 第三版
  $(".notice1").click(function () {
    $(this).removeClass(".contentBodyLeft li ");
    $(this).addClass("notice1");
    $(this).siblings().removeClass("notice1");
    $(this).siblings().addClass(".contentBodyLeft li ");
  }); 
  $(".notice2").click(function () {
    $(this).removeClass(".contentBodyLeft li ");
    $(this).addClass("notice1");
    $(this).siblings().removeClass("notice1");
    $(this).siblings().addClass(".contentBodyLeft li ");
  }); 
  $(".notice3").click(function () {
    $(this).removeClass(".contentBodyLeft li ");
    $(this).addClass("notice1");
    $(this).siblings().removeClass("notice1");
    $(this).siblings().addClass(".contentBodyLeft li ");
  }); 
  $(".notice4").click(function () {
    $(this).removeClass(".contentBodyLeft li ");
    $(this).addClass("notice1");
    $(this).siblings().removeClass("notice1");
    $(this).siblings().addClass(".contentBodyLeft li ");
  }); 

  $(".notice1").click(function() {
    $(".notice1Content").show();
    $(".notice1Content1").hide();
    $(".notice1Content2").hide();
    $(".notice1Content3").hide();

  });
  $(".notice2").click(function() {
    $(".notice1Content1").show();
    $(".notice1Content").hide();
    $(".notice1Content2").hide();
    $(".notice1Content3").hide();
  });
  $(".notice3").click(function() {
    $(".notice1Content2").show();
    $(".notice1Content").hide();
    $(".notice1Content1").hide();
    $(".notice1Content3").hide();
  });
  $(".notice4").click(function() {
    $(".notice1Content3").show();
    $(".notice1Content").hide();
    $(".notice1Content2").hide();
    $(".notice1Content1").hide();
  });

  // 教育教学 （四个模块新闻列表）
  var pagination = {
    total: 0,
    pageSize: 10,
    current: 1,
  }; 
  // 研究课题
  function topicList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml +=`<a target="_blank" href="sixModulesDetails2.html?articleId=${data[i].articleId}">
      <li>
        <p class="ListsTitle">${data[i].title}</p>
          <span class="">${data[i].timeStr}</span>
           <span>|</span>
          <span>
              来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
          </span>
      </li>
    </a>`;
    }
    $(".research").html(listHtml);
  }
  layui.use("laypage", function () {
      var laypage = layui.laypage;
      $.ajax({
        type: "post",
        url: globalConfig.onlineIP + "/api/getNewsGroup",
        success: function(data) {
            $.ajax({
              type: "post",
              dataType: "json",
              data: {
                current: 1,
                groupId: data[8].articleGroupId,
                size: pagination.pageSize,
                current: pagination.current,
              },
              url: globalConfig.onlineIP + "/new/getData",
              success: function(data) {
                  if(data) {
                    // 渲染列表
                    pagination.current = data.current;
                    pagination.size = data.pageSize;
                    pagination.total = data.total;
                    topicList(data.records);
                    // 翻页
                    laypage.render({
                        elem: "page", //layui page id名
                        count: pagination.total, //数据总数，从服务端得到
                        limit: pagination.pageSize, //每页条数设置
                        curr: pagination.current,
                        jump: function(obj, first) {
                          if (!first) {
                              $.ajax({
                                type: "post",
                                url: globalConfig.onlineIP + "/api/getNewsGroup",
                                success: function(data) {
                                    $.ajax({
                                      type: "post",
                                      url: globalConfig.onlineIP + "/new/getData",
                                      dataType: "json",
                                      data: {
                                          groupId: data[8].articleGroupId,
                                          current: obj.curr,         //当前页 current
                                          size: obj.limit,
                                      },
                                      success: function (data) {
                                          if (data) {
                                            pagination.current = data.current;
                                            pagination.size = data.pageSize;
                                            pagination.total = data.total;
                                            topicList(data.records);
                                          }
                                      },
                                    });
                                }
                              })
                          }  
                        },
                    });
                  }else{
                    $(".research").html("暂无数据");
                  }
              },
            });
        },
      });  
  })
  // 教学评估
  function assessmentList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml +=`<a target="_blank" href="sixModulesDetails2.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
   </a>`;
    }
    $(".assessment").html(listHtml);
  }
  layui.use("laypage", function () {
      var laypage = layui.laypage;
      $.ajax({
         type: "post",
         url: globalConfig.onlineIP + "/api/getNewsGroup",
         success: function(data) {
            $.ajax({
               type: "post",
               dataType: "json",
               data: {
                 current: 1,
                 groupId: data[9].articleGroupId,
                 size: pagination.pageSize,
                 current: pagination.current,
               },
               url: globalConfig.onlineIP + "/new/getData",
               success: function(data) {
                  if(data) {
                     // 渲染列表
                     pagination.current = data.current;
                     pagination.size = data.pageSize;
                     pagination.total = data.total;
                     assessmentList(data.records);
                     // 翻页
                     laypage.render({
                        elem: "page1", //layui page id名
                        count: pagination.total, //数据总数，从服务端得到
                        limit: pagination.pageSize, //每页条数设置
                        curr: pagination.current,
                        jump: function(obj, first) {
                           if (!first) {
                              $.ajax({
                                 type: "post",
                                 url: globalConfig.onlineIP + "/api/getNewsGroup",
                                 success: function(data) {
                                    $.ajax({
                                       type: "post",
                                       url: globalConfig.onlineIP + "/new/getData",
                                       dataType: "json",
                                       data: {
                                          groupId: data[9].articleGroupId,
                                          current: obj.curr,         //当前页 current
                                          size: obj.limit,
                                       },
                                       success: function (data) {
                                          if (data) {
                                             pagination.current = data.current;
                                             pagination.size = data.pageSize;
                                             pagination.total = data.total;
                                             assessmentList(data.records);
                                          }
                                       },
                                    });
                                 }
                              })
                           }  
                        },
                     });
                  }else{
                     $(".assessment").html("暂无数据");
                  }
               },
            });
         },
      });  
  })
  // 教学诊断与改进
  function improvementList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml +=`<a target="_blank" href="sixModulesDetails2.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
   </a>`;
    }
    $(".improvement").html(listHtml);
  }
  layui.use("laypage", function () {
    var laypage = layui.laypage;
    $.ajax({
       type: "post",
       url: globalConfig.onlineIP + "/api/getNewsGroup",
       success: function(data) {
          $.ajax({
             type: "post",
             dataType: "json",
             data: {
               current: 1,
               groupId: data[10].articleGroupId,
               size: pagination.pageSize,
               current: pagination.current,
             },
             url: globalConfig.onlineIP + "/new/getData",
             success: function(data) {
                if(data) {
                   // 渲染列表
                   pagination.current = data.current;
                   pagination.size = data.pageSize;
                   pagination.total = data.total;
                   improvementList(data.records);
                   // 翻页
                   laypage.render({
                      elem: "page2", //layui page id名
                      count: pagination.total, //数据总数，从服务端得到
                      limit: pagination.pageSize, //每页条数设置
                      curr: pagination.current,
                      jump: function(obj, first) {
                         if (!first) {
                            $.ajax({
                               type: "post",
                               url: globalConfig.onlineIP + "/api/getNewsGroup",
                               success: function(data) {
                                  $.ajax({
                                     type: "post",
                                     url: globalConfig.onlineIP + "/new/getData",
                                     dataType: "json",
                                     data: {
                                        groupId: data[10].articleGroupId,
                                        current: obj.curr,         //当前页 current
                                        size: obj.limit,
                                     },
                                     success: function (data) {
                                        if (data) {
                                           pagination.current = data.current;
                                           pagination.size = data.pageSize;
                                           pagination.total = data.total;
                                           improvementList(data.records);
                                        }
                                     },
                                  });
                               }
                            })
                         }  
                      },
                   });
                }else{
                  $(".improvement").html("暂无数据");
                }
             },
          });
       },
    });  
  })
  // 工作动态
  function dynamicList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml +=`<a target="_blank" href="sixModulesDetails2.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
   </a>`;
    }
    $(".dynamic").html(listHtml);
  }
  layui.use("laypage", function () {
      var laypage = layui.laypage;
      $.ajax({
        type: "post",
        url: globalConfig.onlineIP + "/api/getNewsGroup",
        success: function(data) {
            $.ajax({
              type: "post",
              dataType: "json",
              data: {
                current: 1,
                groupId: data[11].articleGroupId,
                size: pagination.pageSize,
                current: pagination.current,
              },
              url: globalConfig.onlineIP + "/new/getData",
              success: function(data) {
                  if(data) {
                    // 渲染列表
                    pagination.current = data.current;
                    pagination.size = data.pageSize;
                    pagination.total = data.total;
                    dynamicList(data.records);
                    // 翻页
                    laypage.render({
                        elem: "page3", //layui page id名
                        count: pagination.total, //数据总数，从服务端得到
                        limit: pagination.pageSize, //每页条数设置
                        curr: pagination.current,
                        jump: function(obj, first) {
                          if (!first) {
                              $.ajax({
                                type: "post",
                                url: globalConfig.onlineIP + "/api/getNewsGroup",
                                success: function(data) {
                                    $.ajax({
                                      type: "post",
                                      url: globalConfig.onlineIP + "/new/getData",
                                      dataType: "json",
                                      data: {
                                          groupId: data[11].articleGroupId,
                                          current: obj.curr,         //当前页 current
                                          size: obj.limit,
                                      },
                                      success: function (data) {
                                          if (data) {
                                            pagination.current = data.current;
                                            pagination.size = data.pageSize;
                                            pagination.total = data.total;
                                            dynamicList(data.records);
                                          }
                                      },
                                    });
                                }
                              })
                          }  
                        },
                    });
                  }else{
                    $(".dynamic").html("暂无数据");
                  }
              },
            });
        },
      });  
  })
  
  // 赛事培训 （四个模块新闻列表）
  // 活动通知
  function activityList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml +=`<a target="_blank" href="sixModulesDetails3.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
   </a>`;
    }
    $(".activity").html(listHtml);
  }
  layui.use("laypage", function () {
      var laypage = layui.laypage;
      $.ajax({
        type: "post",
        url: globalConfig.onlineIP + "/api/getNewsGroup",
        success: function(data) {
            $.ajax({
              type: "post",
              dataType: "json",
              data: {
                current: 1,
                groupId: data[12].articleGroupId,
                size: pagination.pageSize,
                current: pagination.current,
              },
              url: globalConfig.onlineIP + "/new/getData",
              success: function(data) {
                  if(data) {
                    // 渲染列表
                    pagination.current = data.current;
                    pagination.size = data.pageSize;
                    pagination.total = data.total;
                    activityList(data.records);
                    // 翻页
                    laypage.render({
                        elem: "page4", //layui page id名
                        count: pagination.total, //数据总数，从服务端得到
                        limit: pagination.pageSize, //每页条数设置
                        curr: pagination.current,
                        jump: function(obj, first) {
                          if (!first) {
                              $.ajax({
                                type: "post",
                                url: globalConfig.onlineIP + "/api/getNewsGroup",
                                success: function(data) {
                                    $.ajax({
                                      type: "post",
                                      url: globalConfig.onlineIP + "/new/getData",
                                      dataType: "json",
                                      data: {
                                          groupId: data[12].articleGroupId,
                                          current: obj.curr,         //当前页 current
                                          size: obj.limit,
                                      },
                                      success: function (data) {
                                          if (data) {
                                            pagination.current = data.current;
                                            pagination.size = data.pageSize;
                                            pagination.total = data.total;
                                            activityList(data.records);
                                          }
                                      },
                                    });
                                }
                              })
                          }  
                        },
                    });
                  }else{
                    $(".activity").html("暂无数据");
                  }
              },
            });
        },
      });  
  })
  // 参赛指南
  function guideList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml +=`<a target="_blank" href="sixModulesDetails3.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
   </a>`;
    }
    $(".guide").html(listHtml);
  }
  layui.use("laypage", function () {
      var laypage = layui.laypage;
      $.ajax({
        type: "post",
        url: globalConfig.onlineIP + "/api/getNewsGroup",
        success: function(data) {
            $.ajax({
              type: "post",
              dataType: "json",
              data: {
                current: 1,
                groupId: data[13].articleGroupId,
                size: pagination.pageSize,
                current: pagination.current,
              },
              url: globalConfig.onlineIP + "/new/getData",
              success: function(data) {
                  if(data) {
                    // 渲染列表
                    pagination.current = data.current;
                    pagination.size = data.pageSize;
                    pagination.total = data.total;
                    guideList(data.records);
                    // 翻页
                    laypage.render({
                        elem: "page5", //layui page id名
                        count: pagination.total, //数据总数，从服务端得到
                        limit: pagination.pageSize, //每页条数设置
                        curr: pagination.current,
                        jump: function(obj, first) {
                          if (!first) {
                              $.ajax({
                                type: "post",
                                url: globalConfig.onlineIP + "/api/getNewsGroup",
                                success: function(data) {
                                    $.ajax({
                                      type: "post",
                                      url: globalConfig.onlineIP + "/new/getData",
                                      dataType: "json",
                                      data: {
                                          groupId: data[13].articleGroupId,
                                          current: obj.curr,         //当前页 current
                                          size: obj.limit,
                                      },
                                      success: function (data) {
                                          if (data) {
                                            pagination.current = data.current;
                                            pagination.size = data.pageSize;
                                            pagination.total = data.total;
                                            guideList(data.records);
                                          }
                                      },
                                    });
                                }
                              })
                          }  
                        },
                    });
                  }else{
                    $(".guide").html("暂无数据");
                  }
              },
            });
        },
      });  
  })
  // 资料下载
  function dataDownloadList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml +=`<a target="_blank" href="sixModulesDetails3.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
   </a>`;
    }
    $(".dataDownload").html(listHtml);
  }
  layui.use("laypage", function () {
      var laypage = layui.laypage;
      $.ajax({
        type: "post",
        url: globalConfig.onlineIP + "/api/getNewsGroup",
        success: function(data) {
            $.ajax({
              type: "post",
              dataType: "json",
              data: {
                current: 1,
                groupId: data[14].articleGroupId,
                size: pagination.pageSize,
                current: pagination.current,
              },
              url: globalConfig.onlineIP + "/new/getData",
              success: function(data) {
                  if(data) {  
                    // 渲染列表
                    pagination.current = data.current;
                    pagination.size = data.pageSize;
                    pagination.total = data.total;
                    dataDownloadList(data.records);
                    // 翻页
                    laypage.render({
                        elem: "page6", //layui page id名
                        count: pagination.total, //数据总数，从服务端得到
                        limit: pagination.pageSize, //每页条数设置
                        curr: pagination.current,
                        jump: function(obj, first) {
                          if (!first) {
                              $.ajax({
                                type: "post",
                                url: globalConfig.onlineIP + "/api/getNewsGroup",
                                success: function(data) {
                                    $.ajax({
                                      type: "post",
                                      url: globalConfig.onlineIP + "/new/getData",
                                      dataType: "json",
                                      data: {
                                          groupId: data[14].articleGroupId,
                                          current: obj.curr,         //当前页 current
                                          size: obj.limit,
                                      },
                                      success: function (data) {
                                          if (data) {
                                            pagination.current = data.current;
                                            pagination.size = data.pageSize;
                                            pagination.total = data.total;
                                            dataDownloadList(data.records);
                                          }
                                      },
                                    });
                                }
                              })
                          }  
                        },
                    });
                  }else{
                    $(".dataDownload").html("暂无数据");
                  }
              },
            });
        },
      });  
  })
  // 精彩赛事
  function marvellousList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml +=`<a target="_blank" href="sixModulesDetails3.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
   </a>`;
    }
    $(".marvellous").html(listHtml);
  }
  layui.use("laypage", function () {
      var laypage = layui.laypage;
      $.ajax({
        type: "post",
        url: globalConfig.onlineIP + "/api/getNewsGroup",
        success: function(data) {
            $.ajax({
              type: "post",
              dataType: "json",
              data: {
                current: 1,
                groupId: data[15].articleGroupId,
                size: pagination.pageSize,
                current: pagination.current,
              },
              url: globalConfig.onlineIP + "/new/getData",
              success: function(data) {
                  if(data) {  
                    // 渲染列表
                    pagination.current = data.current;
                    pagination.size = data.pageSize;
                    pagination.total = data.total;
                    marvellousList(data.records);
                    // 翻页
                    laypage.render({
                        elem: "page7", //layui page id名
                        count: pagination.total, //数据总数，从服务端得到
                        limit: pagination.pageSize, //每页条数设置
                        curr: pagination.current,
                        jump: function(obj, first) {
                          if (!first) {
                              $.ajax({
                                type: "post",
                                url: globalConfig.onlineIP + "/api/getNewsGroup",
                                success: function(data) {
                                    $.ajax({
                                      type: "post",
                                      url: globalConfig.onlineIP + "/new/getData",
                                      dataType: "json",
                                      data: {
                                          groupId: data[15].articleGroupId,
                                          current: obj.curr,         //当前页 current
                                          size: obj.limit,
                                      },
                                      success: function (data) {
                                          if (data) {
                                            pagination.current = data.current;
                                            pagination.size = data.pageSize;
                                            pagination.total = data.total;
                                            marvellousList(data.records);
                                          }
                                      },
                                    });
                                }
                              })
                          }  
                        },
                    });
                  }else{
                    $(".marvellous").html("暂无数据");
                  }
              },
            });
        },
      });  
  })

  // 新闻动态-通知公告（版本三）
  function noticeList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml += `<a target="_blank" href="sixModulesDetails1.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
    </a>`
    }
    $("#notice").html(listHtml);
  }
  layui.use("laypage", function () {
    var laypage = layui.laypage;
    $.ajax({
      type: "post",
      dataType: "json",
      data: {
        groupId: 31,
        current: 1,
        size: pagination.pageSize,
        current: pagination.current,
      },
      url: globalConfig.onlineIP + "/new/getData",
      success: function(data) {
         if(data) {
            // 渲染列表
            pagination.current = data.current;
            pagination.size = data.pageSize;
            pagination.total = data.total;
            noticeList(data.records);
            // 翻页
            laypage.render({
               elem: "noticePage", //layui page id名
               count: pagination.total, //数据总数，从服务端得到
               limit: pagination.pageSize, //每页条数设置
               curr: pagination.current,
                jump: function(obj, first) {
                  if (!first) {
                    $.ajax({
                      type: "post",
                      url: globalConfig.onlineIP + "/new/getData",
                      dataType: "json",
                      data: {
                        groupId: 31,
                        current: obj.curr,         //当前页 current
                        size: obj.limit,
                      },
                      success: function (data) {
                        if (data) {
                          pagination.current = data.current;
                          pagination.size = data.pageSize;
                          pagination.total = data.total;
                          noticeList(data.records);
                        }
                      },
                    });
                  }  
                },
            });
          }else{
            $("#notice").html("暂无数据");
        }
      },
    });
  })

  // 新闻动态-职教资讯（版本三）
  function informationList(data) {
    let len = data.length;
    let listHtml = "";
    for (let i = 0; i < len; i++) {
      listHtml += `<a target="_blank" href="sixModulesDetails1.html?articleId=${data[i].articleId}">
      <li>
         <p class="ListsTitle">${data[i].title}</p>
         <span class="">${data[i].timeStr}</span>
         <span>|</span>
         <span>
            来源：<span class="ListsTitleSpan">${data[i].origin}</span> 
         </span>
      </li>
    </a>`
    }
    $("#information").html(listHtml);
  }
  layui.use("laypage", function () {
    var laypage = layui.laypage;
    $.ajax({
      type: "post",
      dataType: "json",
      data: {
        groupId: 32,
        current: 1,
        size: pagination.pageSize,
        current: pagination.current,
      },
      url: globalConfig.onlineIP + "/new/getData",
      success: function(data) {
         if(data) {
            // 渲染列表
            pagination.current = data.current;
            pagination.size = data.pageSize;
            pagination.total = data.total;
            informationList(data.records);
            // 翻页
            laypage.render({
               elem: "informationPage", //layui page id名
               count: pagination.total, //数据总数，从服务端得到
               limit: pagination.pageSize, //每页条数设置
               curr: pagination.current,
                jump: function(obj, first) {
                  if (!first) {
                    $.ajax({
                      type: "post",
                      url: globalConfig.onlineIP + "/new/getData",
                      dataType: "json",
                      data: {
                        groupId: 32,
                        current: obj.curr,         //当前页 current
                        size: obj.limit,
                      },
                      success: function (data) {
                        if (data) {
                          pagination.current = data.current;
                          pagination.size = data.pageSize;
                          pagination.total = data.total;
                          informationList(data.records);
                        }
                      },
                   });
                  }  
                },
            });
          }else{
            $("#information").html("暂无数据");
        }
      },
    });
  })
});
